package com.liaoyifan.core.util;

import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.Statement;

public class SqlParser {
    public static String compress(String sql) {
        if (sql == null || sql.trim().isEmpty()) {
            return "";
        }
        try {
            Statement statement = CCJSqlParserUtil.parse(sql);
            return statement.toString();
        } catch (Exception e) {
            return sql.trim();
        }
    }
}
